/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package it.polimi.wcalendar.business.security.entity;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author gugu
 */
@Entity
@Table(name = "restore_password")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "RestorePassword.findAll", query = "SELECT r FROM RestorePassword r"),
    @NamedQuery(name = "RestorePassword.findByIdr", query = "SELECT r FROM RestorePassword r WHERE r.idr = :idr"),
    @NamedQuery(name = "RestorePassword.findByTime", query = "SELECT r FROM RestorePassword r WHERE r.time = :time"),
    @NamedQuery(name = "RestorePassword.findByHash", query = "SELECT r FROM RestorePassword r WHERE r.hash = :hash")})
public class RestorePassword implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "Id_r")
    private Integer idr;
    @Basic(optional = false)
    @NotNull
    @Column(name = "time")
    @Temporal(TemporalType.TIMESTAMP)
    private Date time;
    @Basic(optional = false)
    @NotNull
    @Column(name = "hash")
    private int hash;
    @JoinColumn(name = "user", referencedColumnName = "Nickname")
    @ManyToOne(optional = false)
    private User user;

    public RestorePassword() {
    }

    public RestorePassword(Integer idr) {
        this.idr = idr;
    }

    public RestorePassword(Integer idr, Date time, int hash) {
        this.idr = idr;
        this.time = time;
        this.hash = hash;
    }

    public Integer getIdr() {
        return idr;
    }

    public void setIdr(Integer idr) {
        this.idr = idr;
    }

    public Date getTime() {
        return time;
    }

    public void setTime(Date time) {
        this.time = time;
    }

    public int getHash() {
        return hash;
    }

    public void setHash(int hash) {
        this.hash = hash;
    }

    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idr != null ? idr.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof RestorePassword)) {
            return false;
        }
        RestorePassword other = (RestorePassword) object;
        if ((this.idr == null && other.idr != null) || (this.idr != null && !this.idr.equals(other.idr))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "it.polimi.wcalendar.business.security.RestorePassword[ idr=" + idr + " ]";
    }
    
}
